- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.9k
          Allow passing expr metavariable to cfg
          #146961
        
          New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
| Some changes occurred in compiler/rustc_attr_parsing | 
| r? @fee1-dead rustbot has assigned @fee1-dead. Use  | 
      
        
              This comment has been minimized.
        
        
      
    
  This comment has been minimized.
| } | ||
|  | ||
| pass_nonterminal!(n!()); | ||
| //~^ ERROR expected one of `(`, `::`, or `=`, found `!` | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This error is surprisingly different from what you get when "inlining" the macro?
error: expected unsuffixed literal, found `!`
 --> src/main.rs:6:15
  |
6 | #[repr(align(n!()))]
  |               ^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$expr effectively has parentheses around it, so the "inlined" version would look more like #[repr(align((n!())))].
1cd49c1    to
    10f76de      
    Compare
  
    | Just as an update, after #124141 we effectively no longer have nonterminal tokens in the grammar (*). I hoped that some time after #124141 either @nnethercote or me relax these rules in many cases, when there are no backward compatibility concerns at least, and pass the change through lang team, but it didn't happen yet. A number of current hacks like accepting  @Jules-Bertholet You could very well start the same process, just from a different point and accept any token streams that look like cfg predicates as cfg predicates, from any matchers, not just  (*) Or we technically have, but only for compatibility and to avoid extending the language without the lang team process. | 
| As for the current implementation, the new  | 
| This seems reasonable to me. It allows all  @rfcbot merge | 
| Team member @joshtriplett has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! cc @rust-lang/lang-advisors: FCP proposed for lang, please feel free to register concerns. | 
| @rfcbot reviewed | 
| @rfcbot reviewed | 
| 🔔 This is now entering its final comment period, as per the review above. 🔔 | 
| 
 Happy to see a more general version of this, if we can. | 
| @rfcbot reviewed I am in favor of making the "special tokens" and invisible delimiters less visible to the user. | 
| The final comment period, with a disposition to merge, as per the review above, is now complete. As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed. This will be merged soon. | 
This PR allows expanding
exprmetavariables inside the configuration predicates ofcfgandcfg_attrinvocations.For example, the following code will now compile:
There is currently no
macro_rulesfragment specifier that can represent all validcfgpredicates.metacomes closest, but excludestrueandfalse. By fixing that, this change makes it easier to write declarative macros that parsecfgorcfg_attrinvocations, for example #146281.@rustbot label T-lang needs-fcp A-attributes A-cfg A-macros